HAVE_ENESIM=$(shell pkg-config --exists enesim 2>/dev/null && echo 'yes')
HAVE_ENESIM_OPENCL=$(shell pkg-config --exists enesim_opencl 2>/dev/null && echo 'yes')
HAVE_ENESIM_OPENGL=$(shell pkg-config --exists enesim_opengl 2>/dev/null && echo 'yes')
HAVE_ESCEN=$(shell pkg-config --exists escen 2>/dev/null && echo 'yes')

CFLAGS = -g
LIBS =

ifeq ($(HAVE_ENESIM),yes)
CFLAGS += $(shell pkg-config --cflags enesim)
LIBS += $(shell pkg-config --libs enesim)
endif

ifeq ($(HAVE_ENESIM_OPENCL),yes)
CFLAGS += $(shell pkg-config --cflags enesim_opencl) -DHAVE_OPENCL
LIBS += $(shell pkg-config --libs enesim_opencl)
endif

ifeq ($(HAVE_ENESIM_OPENGL),yes)
CFLAGS += $(shell pkg-config --cflags enesim_opengl) -DHAVE_OPENGL
LIBS += $(shell pkg-config --libs enesim_opengl)
endif

ifeq ($(HAVE_ESCEN),yes)
CFLAGS += $(shell pkg-config --cflags escen) -DHAVE_ESCEN
LIBS += $(shell pkg-config --libs escen)
endif

BINS = benchmark
all: $(BINS)

benchmark_SRCS = benchmark.c

benchmark_OBJS = $(benchmark_SRCS:.c=.o)
benchmark: $(benchmark_OBJS)
	$(RM) $@
	$(CC) $(benchmark_OBJS) -o $@ $(LIBS) $(CFLAGS) $(LDFLAGS) -leina -lender

.c.o:
	$(CC) $(FLAGS) $(CFLAGS) -c $< -o $@
clean::
	rm -rf $(BINS) *.o *~
